package com.example.tellwin;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.text.TextUtils;

import com.apkfuns.logutils.LogUtils;
import com.example.tellwin.base.CpBaseActivty;
import com.example.tellwin.event.ShareIntentEvent;
import com.example.tellwin.mine.act.LoginRegisterActivity;

import org.greenrobot.eventbus.EventBus;
import org.song.videoplayer.rederview.TextureRenderView;

public class SplashActivity extends CpBaseActivty {

    String id;
    String type;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_splash);
        initViews();
        initEvents();
        initDatas();
    }

    @Override
    protected void initViews() {

    }

    @Override
    protected void initEvents() {

    }

    @Override
    protected void initDatas() {

        Uri uri = getIntent().getData();
        if (uri != null) {
            LogUtils.d(uri);
            id = uri.getQueryParameter("id");
            type = uri.getQueryParameter("type");
            LogUtils.d(id);
            LogUtils.d(type);
            if(TextUtils.isEmpty(id)|| TextUtils.isEmpty(type)){

            }else {
                AppHelper.getInstance().setShareId(id);
                AppHelper.getInstance().setShareType(type);
            }

        }


        Handler handler = new Handler();
        handler.postDelayed(new Runnable() {
            @Override
            public void run() {

                if (AppHelper.getInstance().isLogin()) {
                    if (AppHelper.getInstance().getUser().getIsIdentity() == 0) {
                        Intent intent = new Intent(SplashActivity.this, IdentitySelectActivity.class);
                        startActivity(intent);
                        finish();
                    } else {
                        Intent intent = new Intent(SplashActivity.this, MainActivity.class);
                        startActivity(intent);
                        finish();
                    }
                }else {
                    Intent intent = new Intent(SplashActivity.this, LoginRegisterActivity.class);
                    startActivity(intent);
                    finish();
                }
            }
        }, 1500);
    }
}
